/**
 * Created by Saxon Cheng on 2017/3/16.
 */
import * as ActionType from "../constants/ActionType"
const initialState = {
    workId:'',
    workType: "",
    userId:'',
    payType: "",
    isPaying:false,
    paySuccess: false,
    params:new Object(),
    errMsg:''
};

export default function payReducer(state = initialState, action) {
    switch (action.type) {
        case ActionType.FETCH_PRODUCTID_START:
            return Object.assign({}, state, {
                isPaying: true,
                workId:action.workId,
                workType:action.workType,
                payType:action.payType,
                userId:action.userId,
                paySuccess:false,
            });
        case ActionType.FETCH_PRODUCTID_DONE:
            return Object.assign({}, state, {
                isPaying: false,
                params:action.params,
                paySuccess:true
            });
        case ActionType.FETCH_PRODUCTID_ERROR:
            return Object.assign({}, state, {
                isPaying: false,
                paySuccess:false,
                errMsg:action.errMsg
            })
        default:
            return state;
    }
}